package com.itheima.loop;

import java.util.Random;
import java.util.Scanner;

public class RandomDemo2 {
    public static void main(String[] args) {
        Scanner insert = new Scanner(System.in);
        Random r = new Random();
        int i = r.nextInt(100) + 1;
        while (true) {
            System.out.println("请输入1-100之间的整数：");
            int guess  = insert.nextInt();
            if (guess > i) {
                System.out.println("您猜测的数字过大！");
            }
            else if (guess < i) {
                System.out.println("您猜测的数字过小！");
            } else {
                System.out.println("恭喜您猜对了！");
                break;
            }
        }
    }
}
